package fox.framework.rpc.client.message.response;

import fox.framework.rpc.message.MappedRpcHeader;
import fox.framework.rpc.message.RpcHeader;

import java.util.Collection;

/**
 * @author cuichao
 * @Description: RpcClientResponseAPI
 * @Date: create in 2021/1/23 15:32
 */
public final class RpcClientResponseAPI implements RpcClientResponse {

    private String protocol;

    private int status;

    private RpcHeader header = new MappedRpcHeader();

    private ResponseEntity entity;


    @Override
    public String getProtocol() {
        return protocol;
    }

    @Override
    public int getStatus() {
        return status;
    }


    @Override
    public String getHeader(String name) {
        return header.getHeader(name);
    }

    @Override
    public Collection<String> getHeaderNames() {
        return header.getHeaderNames();
    }

    @Override
    public int getContentLength() {
        return Integer.valueOf(header.getHeader(RpcHeader.CONTENT_LENGTH));
    }

    @Override
    public String getContentType() {
        return header.getHeader(RpcHeader.CONTENT_TYPE);
    }


    @Override
    public ResponseEntity getEntity() {
        return entity;
    }

    void setProtocol(String protocol){
        this.protocol = protocol;
    }

    void setStatus(int status){
        this.status = status;
    }

    void setHeader(String name, String value){
        header.setHeader(name,value);
    }

    void setEntity(ResponseEntity entity){
        this.entity =entity;
    }

}
